package com.itheima.mall.service.umsService;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.mall.mapper.umsMapper.UmsAdminMapper;
import com.itheima.pojo.ums.UmsAdmin;
import com.itheima.pojo.ums.UmsRoleMenuRelation;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;


@DubboService
public class UmsAdminServiceImpl implements UmsAdminApi {

    @Autowired
    private UmsAdminMapper umsAdminMapper;



    /**
     * 根据用户名查找用户是否存在
     * @param username
     * @return
     */
    @Override
    public UmsAdmin selectByUsername(String username) {
        //1.设置查询条件
        LambdaQueryWrapper<UmsAdmin> wrapper =new LambdaQueryWrapper<>();
        //2.根据用户名来进行查找
        wrapper.eq(UmsAdmin::getUsername,username);
        //查找到用户并返回
        UmsAdmin umsAdmin = umsAdminMapper.selectOne(wrapper);
        return umsAdmin;
    }

    /**
     * 删除指定用户信息
     * @param id
     */
    @Override
    public void deleteById(Long id) {
        LambdaQueryWrapper<UmsAdmin> wrapper =new LambdaQueryWrapper<>();
        wrapper.eq(UmsAdmin::getId,id);
        umsAdminMapper.deleteById(wrapper);
    }

    /**
     * 指定id查找用户信息
     * @param id
     * @return
     */
    @Override
    public UmsAdmin selectById(String id) {
        LambdaQueryWrapper<UmsAdmin> wrapper =new LambdaQueryWrapper<>();
        wrapper.eq(UmsAdmin::getId,id);
        UmsAdmin umsAdmin = umsAdminMapper.selectById(wrapper);
        return umsAdmin;
    }



}
